Validation for using the same service-name for different resources#1673
Conversation
| public static final String SERVICE_INSTANCE_0_PLAN_UPDATE_FAILED_IGNORING_FAILURE = "Service instance: \"{0}\" plan update failed, ignoring failure..."; | ||
| public static final String SERVICE_INSTANCE_0_PARAMETERS_UPDATE_FAILED_IGNORING_FAILURE = "Service instance: \"{0}\" parameters update failed, ignoring failure..."; | ||
| public static final String SERVICE_INSTANCE_0_TAGS_UPDATE_FAILED_IGNORING_FAILURE = "Service instance: \"{0}\" tags update failed, ignoring failure..."; | ||
| public static final String ONLY_FIRST_SERVICE_WILL_BE_CREATED = "[WARNING] Only the first service will be created because provided 'service-name' fields are duplicated! All other services with the same 'service-name' will be ignored!"; |
There was a problem hiding this comment.
is the '[WARNING]' text consistent with any other message?
There was a problem hiding this comment.
It isn't actually - just made more sense to me - but will make it like the others, fixed
| .collect(Collectors.toSet()); | ||
| if (resolvedServiceInstancesNames.size() != resolvedServiceInstancesNamesWithoutDuplicates.size()) { | ||
| getStepLogger().warn( | ||
| Messages.ONLY_FIRST_SERVICE_WILL_BE_CREATED); |
There was a problem hiding this comment.
it makes more to sense to actually print out the specific duplicated service names instead of the generic warning
| context.setVariable(Variables.SERVICES_TO_CREATE_COUNT, servicesToCreate.size()); | ||
| } | ||
|
|
||
| private void checkForDuplicatedServiceNameFields(List<CloudServiceInstanceExtended> resolvedServiceInstances) { |
There was a problem hiding this comment.
this is only in the 'batchedServices...' step - is there an alternative flow in the diagram that doesn't split the service in batches and will it not validate in that case?
c1a1d01 to
9e8348b
Compare
LMCROSSITXSADEPLOY-1661
ffec30f to
289b9c2
Compare
| public static final String SERVICE_INSTANCE_0_PLAN_UPDATE_FAILED_IGNORING_FAILURE = "Service instance: \"{0}\" plan update failed, ignoring failure..."; | ||
| public static final String SERVICE_INSTANCE_0_PARAMETERS_UPDATE_FAILED_IGNORING_FAILURE = "Service instance: \"{0}\" parameters update failed, ignoring failure..."; | ||
| public static final String SERVICE_INSTANCE_0_TAGS_UPDATE_FAILED_IGNORING_FAILURE = "Service instance: \"{0}\" tags update failed, ignoring failure..."; | ||
| public static final String ONLY_FIRST_SERVICE_WILL_BE_CREATED = "Only the first service will be created because provided 'service-name' fields are duplicated! All other services with the same 'service-name' will be ignored! Duplicated names: "; |
There was a problem hiding this comment.
Small typo:
".. created because the provided 'service-name' .."
| List<String> duplicatedNames = getDuplicatedNames(resolvedServiceInstancesNames); | ||
| if (!duplicatedNames.isEmpty()) { | ||
| getStepLogger().warn( | ||
| Messages.ONLY_FIRST_SERVICE_WILL_BE_CREATED + String.join(" ", duplicatedNames)); |
There was a problem hiding this comment.
Avoid using the string concatenation with the + operator, for the message, and instead use placeholders {0}.
| List<String> duplicatedNames = new ArrayList<>(); | ||
| Map<String, Integer> frequencyOfNamesMap = new HashMap<>(); | ||
| for (String name : resolvedServiceInstancesNames) { | ||
| frequencyOfNamesMap.put(name, frequencyOfNamesMap.getOrDefault(name, 0) + 1); |
There was a problem hiding this comment.
This line could be replaced by frequencyOfNamesMap.merge(name, 1, Integer::sum);
There was a problem hiding this comment.
Fixed, thank you for the suggestion!
LMCROSSITXSADEPLOY-1661
This reverts commit 3ddb37b. LMCROSSITXSADEPLOY-1661
56242a9 to
5a045a6
Compare
LMCROSSITXSADEPLOY-1661
LMCROSSITXSADEPLOY-1661